<script type="text/javascript">
	try{ace.settings.check('sidebar' , 'fixed')}catch(e){}
</script>

<div class="sidebar-shortcuts" id="sidebar-shortcuts">
	
</div><!-- #sidebar-shortcuts -->

<ul class="nav nav-list">
<?php
	$roles=Rights::getAssignedRoles(Yii::app()->user->getId());
	foreach($roles as $role) $roleLog = $role->name;
	$sql ="select sm.* from sys_menu sm
			inner join sys_menu_role smr on sm.id = smr.sys_menu_id
			where smr.authitem_name = '$roleLog'
			order by sm.id";
	$result = Yii::app()->db->createCommand($sql)->queryAll();
	foreach($result as $val =>$r){
		if($r['parent_id']=='' && $r['has_child']==0){
			echo "<li class='id-".$r['id']."'><a href='". Yii::app()->createUrl($r['url'])."'><i class='".$r['icon']."'></i> <span class='menu-text'>".$r['menu']."</span></a></li>";
		}
		if($r['parent_id']=='' && $r['has_child']==1){
			echo "<li class='id-".$r['id']."'>";
			echo "<a class='dropdown-toggle' href='#'>
					<i class='".$r['icon']."'></i> 
					<span class='menu-text'>".$r['menu']."</span> 
					<b class='arrow icon-angle-down'></b>
				</a>";
				echo "<ul class='submenu'>";
				foreach($result as $value =>$row){
					if($row['parent_id']!='' && $row['parent_id']==$r['id']){
						if($row['has_child']==0){
							echo "<li class='id-".$row['id']."'><a href='". Yii::app()->createUrl($row['url'])."'><span>".$row['menu']."</span> </a></li>";
						}
						if($row['has_child']==1){
							echo "<li class='id-".$row['id']."'>";
							echo "<a class='dropdown-toggle' href='#'>
										<i class='".$row['icon']."'></i> 
										<span>".$row['menu']."</span> 
										<b class='arrow icon-angle-down'></b>
									</a>";
								echo "<ul class='submenu'>";
								foreach($result as $value2 =>$row2){
									if($row2['parent_id']!='' && $row2['parent_id']==$row['id']){
										if($row2['has_child']==0){
											echo "<li class='id-".$row2['id']."'><a href='". Yii::app()->createUrl($row2['url'])."'><span>".$row2['menu']."</span> </a></li>";
										}
										if($row2['has_child']==1){
											echo "<li class='id-".$row2['id']."'>";
											echo "<a class='dropdown-toggle' href='#'>
														<i class='".$row2['icon']."'></i> 
														<span>".$row2['menu']."</span> 
														<b class='arrow icon-angle-down'></b>
													</a>";
											echo "<ul class='submenu'>";
											foreach($result as $value3 =>$row3){
												if($row3['parent_id']!='' && $row3['parent_id']==$row2['id']){
													echo "<li class='id-".$row3['id']."'><a href='". Yii::app()->createUrl($row3['url'])."'><span>".$row3['menu']."</span> </a></li>";
												}
											}
											echo "</ul>";
											echo "</li>";
										}
									}
									
								}
								echo "</ul>";
							echo "</li>";	
						}
					}
				}
				echo "</ul>";
			echo "</li>";
		}
	}
?>
</ul>


<div class="sidebar-collapse" id="sidebar-collapse">
	<i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
</div>

<script type="text/javascript">
	try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
</script>